package com.atdel.oop;


/**
 * @BelongsProject: java_study
 * @BelongsPackage: com.atdel.oop
 * @Author: Del
 * @CreateTime: 2025-02-28  09:53
 * @Description: TODO
 * @Version: 1.0
 */
public class Phone {
    private String brand;
    private String name;
    private double price;
    private String[] Contact;

    public Phone() {
    }

    public Phone(String brand, String name, double price, String[] Contact) {
        this.brand = brand;
        this.name = name;
        this.price = price;
        this.Contact = Contact;
    }

    public String getBrand() {
        return brand;
    }

    public void setBrand(String brand) {
        this.brand = brand;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public double getPrice() {
        return price;
    }

    public void setPrice(double price) {
        this.price = price;
    }

    public String[] getContact() {
        return Contact;
    }

    public void setContact(String[] contact) {
        if (contact.length > 10) {
            System.out.println("联系人个数不能超过10个");
            return;
        }
        Contact = contact;
    }

    public void stl() {
        System.out.println(this.name + "开始上网.......");
    }

    // 给某个联系不发短信
    public void sendMessage(String name) {
        System.out.println(this.name + "给" + name + "不发短信");
    }

    public void sendMessage(String name, String message) {
        boolean contactExists = false;
        for (int i = 0; i < this.Contact.length; i++) {
            if (this.Contact[i].equals(name)) {
                contactExists = true;
                System.out.println(this.name + "给" + name + "发短信, 内容为：" + message);
                break;
            }
        }
        if (!contactExists) {
            System.out.println("给匿名用户发送信息, 内容为：" + message);
        }
    }
}
